import {
  Column,
  Entity,
  JoinTable,
  ManyToMany,
  PrimaryGeneratedColumn,
} from 'typeorm';
import { SystemUser } from '../../system-user/entities/system-user.entity';
import { Menu } from '../../menus/entities/menu.entity';
import { Teacher } from '../../teacher/entities/teacher.entity';
import { Student } from '../../student/entities/student.entity';
/**
 * 角色
 */
@Entity()
export class Role {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ comment: '角色姓名', unique: true })
  name: string;

  @ManyToMany(() => SystemUser, (systemUser) => systemUser.roles)
  systemUsers: SystemUser[];

  @ManyToMany(() => Teacher, (teacher) => teacher.roles)
  teachers: Teacher[];

  @ManyToMany(() => Student, (student) => student.roles)
  students: Student[];

  @ManyToMany(() => Menu)
  @JoinTable({
    name: 'menu_role',
  })
  menus: Menu[];
}
